<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>射击成绩管理</title>
<%@ include file="/common/include.jsp"%>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script language="javascript" type="text/javascript"
	src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
<style>
.tab_c LI {
	PADDING-LEFT: 9px; DISPLAY: inline; FLOAT: left; MARGIN-RIGHT: 3px
}
</style>
<script type="text/javascript">	
$(document).ready(function() {
	$("#select_terminal").fancybox({'width':'50%','height':'70%','type': 'iframe','autocenter':true
		,'onClosed':function(){
			if(window.selectTeminaleNode == null || window.selectTeminaleNode == undefined)
				return;
			$("#dis_tm_nm").val(window.selectTeminaleNode.name);
			$("#dis_tm_cd").val(window.selectTeminaleNode.type + ":" + window.selectTeminaleNode.id);
		}
	});
	
	// 训练单位级联搜索初始化
	$.ajax({
		url:"${pageContext.request.contextPath}/unit/getUnitList/1",
		type: "post",
		contentType: "application/json",
		async: false,
		dataType: "json",
		success: function (data) {
			if (data.length <= 0){
				alert("该大队还没创建分队，请先创建分队");
			}else{
				$("#unitByNewTeamId").empty();
				$("#unitByNewTeamId").append("<option value=\"\">请选择分队</option>");
				$("#unitByNewTeamId").attr("disabled","disabled");
				$("#unitByNowClassId").empty();
				$("#unitByNowClassId").append("<option value=\"\">请选择班</option>");
				$("#unitByNowClassId").attr("disabled","disabled");
				for (var i=0;i<data.length;i++)
				{
					$("#unitByNowGroupId").append("<option value=\"" + data[i].id + "\">" + data[i].name + "</option>");
				}
			}
	    }
	});
	
	// 训练单位级联搜索
	$("#unitByNowGroupId").change(function(){
		var unitByNowGroupId_var = $(this).val();
		$("#unitByNewTeamId").empty();
		$("#unitByNewTeamId").append("<option value=\"\">请选择分队</option>");
		if (unitByNowGroupId_var.length > 0)
		{
			$.ajax({
				url:"${pageContext.request.contextPath}/unit/getUnitList/" + unitByNowGroupId_var,
				type: "post",
				contentType: "application/json",
				async: false,
				dataType: "json",
				success: function (data) {
					if (data.length <= 0){
						alert("该大队还没创建分队，请先创建分队");
					}else{
						
//						$("#unitByNowClassId").empty();
//						$("#unitByNowClassId").append("<option value=\"\">请选择班</option>");
//						$("#unitByNowClassId").attr("disabled","disabled");
						for (var i=0;i<data.length;i++)
						{
							$("#unitByNewTeamId").append("<option value=\"" + data[i].id + "\">" + data[i].name + "</option>");
						}
						$("#unitByNewTeamId").removeAttr("disabled");
						
						
					}
	    		}
			});
		}
	});
	
	// 训练单位级联搜索
	$("#unitByNewTeamId").change(function(){
/**		var unitByNewTeamId_var = $(this).val();
		if (unitByNewTeamId_var.length > 0){
			$.ajax({
				url:"${pageContext.request.contextPath}/unit/getUnitList/" + $(this).val(),
				type: "post",
				contentType: "application/json",
				async: false,
				dataType: "json",
				success: function (data) { 
					if (data.length <= 0){
						alert("该分队还没创建班，请先创建班");
					}else{
						$("#unitByNowClassId").empty();
						$("#unitByNowClassId").append("<option value=\"\">请选择班</option>");
						for (var i=0;i<data.length;i++)
						{
							$("#unitByNowClassId").append("<option value=\"" + data[i].id + "\">" + data[i].name + "</option>");
						}
						$("#unitByNowClassId").removeAttr("disabled");
					}
	    		}
			});
		}
		**/
	});
	
});
var s=new Array();
$(function()
{
	var temp = "${tmcd}";
	var postData = {betm:"2013-01-01",edtm:"2099-12-30"};
	if( temp != ""){
		postData.tmcd = temp;
	} else {
		postData.dscd = "1";
	}
	$("#gridTable").jqGrid({
		datatype: "json",
		url:contextPath+'/shootScore/statistic',
		postData: postData,
		mtype: 'POST',
		prmNames : {search : "search"}, 
		colNames:["训练单位","学员总数","优秀人数","良好人数","及格人数","不及格人数","及格率"],
		colModel:[
			{name:'unitName', index:'unitName', sortable:false, width:70, align:"center"},
			{name:'totalNum',index:'totalNum',sorttype:"string", width:70, sortable:false},
			{name:'excellentNum',index:'excellentNum', width:70, sortable:false},
			{name:'goodNum',index:'goodNum', width:70, sortable:false},
			{name:'passNum',index:'passNum', width:70, sortable:false},
			{name:'failNum',index:'failNum', width:70, sortable:false},
			{name:'passRate',index:'passRate', width:70, align:"center", sortable:false,
				formatter:function(cellvalue, options, rowObject){
					var result = "";
					if (rowObject.totalNum == 0){
						result = "0";
					} else {
						result += (100-rowObject.failNum*100/rowObject.totalNum).toFixed(2);
						result += "%";
					}
					return result;
				}
			}
		],
		sortname:'unitName',
		sortorder:'desc',
		viewrecords:true,
		rowNum:15,
		height:'auto',
		width:799,
		rowList:[10,15,30,60],
		multiselect: false,
		scrollrows: true,
		pager:"#gridPager",
		jsonReader:{
			repeatitems : false
        },
		gridComplete: function(){}
	});
	function formatterLocation(cellvalue, options, rowObject){
		var obj = new Object();
		<c:forEach items="${locationList}" var="code">
			obj["${code.cd}"]="${code.cdnm}";
		</c:forEach>
		return obj[cellvalue];
	}
			
	function formatterOption(cellvalue, options, rowObject){
		var str = '<a href=\"${pageContext.request.contextPath}/shootScore/toEdit/' + rowObject.id + '\">修改</a>';
			//+ '&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"${pageContext.request.contextPath}/order_ad/order_ad.listSchedule.do?actionType=page&adplid=' + rowObject.adplid + '\">安排广告</a>';
		return str;
	}
			
	jQuery.fn.center = function(){
		this.css("position","absolute");
		this.css("top", ( ($(window).height() - this.height() ) / 2+$(window).scrollTop()) + "px");
		this.css("left", (( $(window).width() - this.width() ) / 2+$(window).scrollLeft()) + "px");
		return this;
	};

		var msg="slot_delete@slot_create";
        var slotoptionlist = msg.split('@');
        var slotcreatestate = false;
        /**
        *文件名：ad_place.jsp
        *修改人：林辉
        *日期：2013.3.13
        *描述：广告位的删除操作
        */
        for (var i = 0; i < slotoptionlist.length; i++) {
            if (slotoptionlist[i] == 'slot_delete') {
                jQuery("#gridTable").navGrid('#gridPager', {
                    edit: false,
                    add: false,
                    del: false,
                    search: false,
                    refresh: false
                });
            }
            if (slotoptionlist[i] == 'slot_create') {
                slotcreatestate = true;
            }

        }
        if (!slotcreatestate) {
            $('#slotcreatemode').remove();
        }

		var channel='noid';

			if(channel!='noid'&&channel!='')
			{
			jQuery("#channelchange").val(channel);
			$('#channel-noid').addClass('fz_curr');
			$('#channel-noid').siblings().removeClass('fz_curr');
			$('#allchannelname').html("<a href='javascript:getallchannel()'>全部分组</a>");
			$('#slotshowname').html('>  '+$(".fz_list li[id=channel-"+channel+"] a").html());
			}
			var search_word="";

			if (search_word!='')
			{
			$('#search_cd').val(search_word);
			}

			var size_mask="";

			if (size_mask!='')
			{
			$('#sizechange option[value='+size_mask+']').attr('selected',true);
			}
			var type_mask="";

			if (type_mask!='')
			{
			$('#typechange option[value='+type_mask+']').attr('selected',true);
			}
			var staus_mask="4";

			$('#slotstatuslist option[value='+staus_mask+']').attr('selected',true);

			$('#stauschange').val(staus_mask);

			jQuery("#gridTable").jqGrid('navGrid','#gridPager',{edit:false,add:false,del:false,search:false,refresh:false});

			jQuery("#search_cd").keydown(function(e)
			{

			if(e.keyCode==13)
			{
			gridReload();
			}
			});

			$('#search_cd').focus(function()
			{
			var txt_value= $(this).val();
			if(txt_value==this.defaultValue){
			$(this).val("");
			$(this).attr('class',"ss_inp1");
			}

			});
			$('#search_cd').blur(function()
			{

			var txt_value= $(this).val();
			if(txt_value==""){
			$(this).attr('class',"ss_inp");
			$(this).val(this.defaultValue);

			}
			});

			if($("#search_cd").val() == '输入广告位ID或名称关键词' ){
			$('#search_cd').attr('class',"ss_inp");
			}
			else
			{
			$('#search_cd').attr('class',"ss_inp1");
			}
			$('.fz_list li').click(function()
			{

			$(this).addClass('fz_curr');
			$(this).siblings().removeClass('fz_curr');

			});

			$("#gridTable tr:nth-child(2n)").addClass('xxy');
			$('#gridPager').corner("bottom");

			$('#slotnumhelp').html("<span class='statistic'><span class='contextual_shelp'><a href='#'> </a></span></span>");
			$('#slotnumhelp').mousemove(function(){

			$('#key1').show();
			});
			$('#slotnumhelp').mouseleave(function(){

			$('#key1').hide();
			});
			});
			function gridchannelReload(id)
			{
			if($('#searchword').html()!='')
			{
			$('#searchword').html('');
			$("#search_cd").val('输入广告位ID或名称关键词');
			$('#search_cd').attr('class',"ss_inp");
			}
			$('#channelchange').val(id);
			var slot_href=$('#slotlink').val();
			$('#slotcreatemode a').attr('href',slot_href+'&channel='+id);
			$('#allchannelname').html("<a href='javascript:getallchannel()'>全部分组</a>");
			gridReload();
			$('#slotshowname').html(' >  '+$(".fz_list li[id=channel-"+id+"] a").html());
			}
			function getallchannel()
			{
			if($('#searchword').html()!='')
			{
			$('#searchword').html('');
			$("#search_cd").val('输入广告位ID或名称关键词');
			$('#search_cd').attr('class',"ss_inp");
			}
			$('#allchannel').addClass('fz_curr');
			$('#allchannel').siblings().removeClass('fz_curr');
			var slot_href=$('#slotlink').val();
			$('#allchannelname').html("全部分组");
			$('#slotcreatemode a').attr('href',slot_href);
			$('#channelchange').val('');
			$('#slotshowname').html('');


			gridReload();
			}
			
			
/**
*函数名gridReload
*修改人：林辉
*日期：2013.3.13
*描述：增加注释
*/

	function gridReload(){
		var unitByNowGroupId_var = $("#unitByNowGroupId").val();
		var unitByNewTeamId_var = $("#unitByNewTeamId").val();
		var unitByNowClassId_var = $("#unitByNowClassId").val();
		var fromDate_var = $("#fromDate").val();
		var toDate_var = $("#toDate").val();
		var studentName_var = $("#studentName").val();
		if ('输入学员关键词' == studentName_var){
			studentName_var = '';
		}
		$("#gridTable").jqGrid('setGridParam',
				{postData:{
					'unitByNowGroupId' : unitByNowGroupId_var,
					 'unitByNewTeamId' : unitByNewTeamId_var,
					'unitByNowClassId' : unitByNowClassId_var,
					        'fromDate' : fromDate_var,
					          'toDate' : toDate_var,
					     'studentName' : studentName_var
					}}
		).trigger('reloadGrid');
	}
</script>
</head>
<body>
	<div style="Z-INDEX: 999; WIDTH: 150px; DISPLAY: none" id=modifypic
		class=succ_box>
		<div class=succ_l>删除成功!</div>
		<div class=succ_r></div>
	</div>
	<div class=wrapper>
		<jsp:include page="/common/header.jsp">
			<jsp:param value="4" name="nav" />
		</jsp:include>
		<div class=content>
			<div class=col_l>
				<div class=l_top></div>
				<div class=l_menu>
					<jsp:include page="/common/l_analysis_place.jsp">
						<jsp:param value="1" name="nav" />
					</jsp:include>
				</div>
				
				<div class=l_bottom></div>
			</div>
			<div class=col_r>
				<div class="guide blue">
					<span class=left> 当前位置： <a href="${pageContext.request.contextPath }/ad_place/ad_place.jsp">射击成绩管理</a>
					 	<font id=allchannelname style="display:none;">&gt;全部分组</font>
					 	<font id=slotshowname></font>
					 	<font id=searchword style="display:none;"></font> 
					</span> 
					<span class=right>
						训练单位：
                               <select class="select_1" style="width: 129px" id="unitByNowGroupId" name="unitByNowGroupId">
									<option value="">请选择大队</option>
									<c:forEach items="${unitByNowGroupList }" var="unitByNowGroup">
										<option value="${unitByNowGroup.id }">${unitByNowGroup.name }</option>
									</c:forEach>
								</select>
								<select class="select_1" style="width: 129px" id="unitByNewTeamId" name="unitByNewTeamId" disabled="disabled">
									<option value="">请选择分队</option>
								</select>
								<!-- 
								<select class="select_1" style="width: 129px" id="unitByNowClassId" name="unitByNowClassId" disabled="disabled">
									<option value="">请选择班</option>
								</select>
					 			-->
						
						<input onclick="gridReload()" 
							src="${pageContext.request.contextPath}/images/search.png"
							type=image />
						<span class="down_bb"><a href="javascript:gridReload('download');">导出报表</a></span> 
					</span>
				</div>
				<div class=top_title>
					<div class=tab_l></div>
					<div class=tab_c>
						
					</div>
					<div class=tab_r></div>
				</div>
				
				<div style="">
				<table id=gridTable class="blue "></table>
				</div>
				<div id=gridPager></div>
			</div>
			<div class=clear></div>
			<div style="DISPLAY: none" id=memcache_img></div>
		</div>
		<div class=footer>CopyRight &copy;Research Institute of Computer
			Systems of SCUT. All Rights Reserved</div>
	</div>
	<!--  帮助小提示  -->
<script>
	function showHelp(obj){
	var help = document.getElementById("key"+obj).style.display;
	document.getElementById("key"+obj).style.display="";
	
	} 
	
	function closeHelp(obj){
	var help = document.getElementById("key"+obj).style.display;
	document.getElementById("key"+obj).style.display="none";
	}
</script>
</body>
</html>